# -*- mode: org; fill-column: 80; -*-
#+TITLE: Watching Files
#+AUTHOR: Zelphir Kaltstahl
#+STARTUP: content inlineimages entitiesplain nologdone nologreschedule nologredeadline nologrefile
#+TODO: TODO WIP | DONE
#+DATE: <2021-05-13 Do>
#+LANGUAGE: English
#+PRIORITIES: A C C

* Listening for file writes

** Requirements

- ~inotify-tools~ (~sudo apt-get install inotify-tools~)

** Command

#+begin_src shell
inotifywait \
    --monitor <FILE> \
    --event <EVENT> \
    | while read -r WRITTEN_FILE EVENTS;
      do
          printf "%s was written\n" "${WRITTEN_FILE}";
      done
#+end_src

In the above command replace as follows:

- ~<FILE>~: the file you want to watch
- ~<EVENT>~: ~'CLOSE_WRITE'~ for being notified when writing of the file has finished
